<?php include $this->header();?>
<?php if(false) {?>
<link rel="stylesheet" rev="stylesheet" href="../../../images/admincp/style.css" type="text/css" media="all" />
<?php }?>
<a href="<?=UE_Url::make('info/admin/add/filter/cat_id/'.(isset($_GET['cat_id']) ? $_GET['cat_id'] : ''))?>" class="btn-r-top">添加文章</a>

<div class="pd mt bd search-bar">
  <form method="get" enctype="application/x-www-form-urlencoded" target="_self">
      <select id="cat_id" onchange="window.location='index.php?app=info&ctl=admin&act=list&cat_id='+this.value">
          <option value="all&id=all">所有文章</option>
          <?php foreach($_cats as $_cat) :?>
          <option value="<?=$_cat['cat_id']?>" <?php if(!empty($_GET['cat_id']) && $_cat['cat_id'] == $_GET['cat_id']) {?>selected="selected"<?php }?>><?=$_cat['icon']?><?=$_cat['cat_name']?></option>
          <?php endforeach;?>
      </select>
      <input type="hidden" name="app" value="<?=$app?>" />
      <input type="hidden" name="ctl" value="<?=$ctl?>" />
      <input type="hidden" name="act" value="<?=$act?>" />
      <input type="hidden" name="id" value="<?=$id?>" />
      <input type="text" name="keyword" value="<?php if(empty($_GET['keyword'])){?>请输入关键词<?php } else { print $_GET['keyword'];}?>" onfocus="if(this.value=='请输入关键词') this.value=''" onblur="if(this.value=='') this.value='请输入关键词'" size="30" />
      <input type="submit" value="搜索" class="btn" />
  </form>
  <div class="search-bar-tab">
  <a href="<?=UE_Url::make('info/admin/list/all')?>" <?php if($this->id == 'all') {?> class="current"<?php }?>>所有</a>
  <a href="<?=UE_Url::make('info/admin/list/filter/status/1')?>" <?php if(isset($_GET['status']) && $_GET['status'] == 1) {?> class="current"<?php }?>>已发布</a>
  <a href="<?=UE_Url::make('info/admin/list/filter/status/0')?>" <?php if(isset($_GET['status']) && $_GET['status'] == 0) {?> class="current"<?php }?>>草稿</a>
  <a href="<?=UE_Url::make('info/admin/list/filter/status/-1')?>" <?php if(isset($_GET['status']) && $_GET['status'] == -1) {?> class="current"<?php }?>>回收站</a>
  </div>
</div>

<form method="post">
  <div class="p1 mt bd bg">
      <table class="list rank" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr class="th">
          <td align="center" width="40"><input type="checkbox" id="list-check-all" /></td>
          <td align="center" width="40">排序</td>
          <td align="center" width="40">ID</td>
          <td align="left">文章标题</td>
          <td align="center" width="120">分类</td>
          <td align="center" width="126">添加时间</td>
          <td align="center" width="40">发布</td>
          <td width="145" align="center">管理操作</td>
        </tr>
        <?php foreach ($list as $info) {?>
        <tr class="bb">
          <td align="center"><input type="checkbox" class="list-check" name="list-check[<?=$info['info_id']?>]" /></td>
          <td align="center"><input type="text" name="cat_order[<?=$info['info_id']?>]" value="<?=$info['info_order']?>" size="3" style="text-align:center;" /></td>
          <td align="center"><?=$info['info_id']?></td>
          <td align="left"><a href="<?=UE_Url::make('info/show/item/'.$info['info_id'])?>" target="_blank"><?=$info['info_title']?></a></td>
          <td align="center"><?=empty($info['cat_id']) ? '未分类' : $_cats[$info['cat_id']]['cat_name']?></td>
          <td align="center"><?=date('Y-m-d H:i:s', $info['info_dateline'])?></td>
          <td align="center"><?php if($info['info_status'] == 1) {?><span class="green">√</span><?php } else {?><span class="red">×</span><?php } ?></td>
          <td align="center"><a href="<?=UE_Url::make('info/show/item/'.$info['info_id'])?>" target="_blank">查看</a> | <a href="<?=UE_Url::make('info/admin/edit/'.$info['info_id'])?>">编辑</a> | <a href="<?=$info['info_id'] == 3 ? UE_Url::make('info/admin/del/'.$info['info_id']) : UE_Url::make('info/admin/del/'.$info['info_id'])?>" onclick="return confirm('您确定要删除该文章吗?')">删除</a></td>
        </tr>  	
        <?php }?>
      </table>
      <div class="pd"><?=$paging?></div>
  </div>
  
  <div class="mt bd bg pd">
      <div class="ui-widget">
          <table width="100%" cellspacing="0" cellpadding="0" border="0" class="batopt">
              <tr>
                <td width="40" class="font12_title"><div align="center">操作</div></td>
                <td width="860" class="font12_title">
                    <div align="left">
                      <select name="optype" id="optype">
                        <option value="sort" selected="selected">排序</option>
                        <option value="pub">发布</option>
                        <option value="draft">草稿</option>
                        <option value="trash">回收站</option>
                        <option value="del">彻底删除</option>
                      </select>
                      <input type="submit" value="确定" class="btn" name="submit" onclick="if($('#optype').attr('value') == 'del') if(!confirm('确定要删除这些文章吗？')) return false;">
                     （该操作为批量处理操作，操作前，请在选择列上打钩）           
                   </div>
                </td>
              </tr>
        </table>
    </div>
</div>

</form>
<script type="text/javascript">
//<![CDATA[

$('#list-check-all').click(function(){
	if($(this).attr('checked')) {
		$('.list-check').attr('checked', 'checked');
	} else {
		$('.list-check').removeAttr('checked');
	}
});

function chEnabled(cid) {
	var url = '<?=UE_Url::make("system/category/ajaxChEnabled/")?>&id='+cid;
    $.getJSON(url, function(json){
		if(json.err) {
			alert(json.err);
		} else {
			if(json.r == 1) {
				$('#cat_enabled_'+cid).html('<span class="green">是</span>');
			} else {
			    $('#cat_enabled_'+cid).html('<span class="red">否</span>');
			}
		}
    });
}
//]]>
</script>
<?php include $this->footer();?>